package cn.laixueit.controller;

import cn.laixueit.pojo.Easy;
import cn.laixueit.pojo.Result;
import cn.laixueit.service.EasyService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/easy")
public class EasyController {

    @Autowired
    private EasyService easyService;

    @PostMapping("/finall")
    public Page<Easy> findall(Integer startpage , Integer pagesize, @RequestBody Map map){
        return easyService.findPageCondtion(startpage,pagesize,map);
    }

    @PostMapping("/save")
    public Result save(@RequestBody Easy easy){
        easyService.saveOrUpdate(easy);
        return new Result();
    }
    @GetMapping("/findbyid")
    public Easy findbyid(Integer id){
        return easyService.getById(id);
    }
    @GetMapping("/del")
    public Result del(Integer id){
        easyService.removeById(id);
        return new Result();
    }
}
